package lms.service.impl;

import lms.dao.OperationDao;
import lms.dao.impl.BookDaoImpl;
import lms.entity.Book;
import lms.service.OperationService;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: Grape_Pip
 * @time: 2021/06/22
 */
public class BookServiceImpl<Book> implements OperationService<Book> {

    private OperationDao bookDaoImpl = new BookDaoImpl();

    @Override
    public List<Book> selectedAllInfo() {
        return bookDaoImpl.selectAllInfo();
    }

    @Override
    public boolean deletedById(int vid) {
        int res = bookDaoImpl.deleteById(vid);
        if (res == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean updatedById(int vid, Book object) {
        int res = bookDaoImpl.updateById(vid, object);
        if (res == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean updateStocksById(int bid, int bNum) {
        int res = bookDaoImpl.updateStockById(bid, bNum);
        if (res == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public boolean insertedInfo(Book object) {
        int res = bookDaoImpl.insertInfo(object);
        if (res == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public Book selectedById(int vid) {
        return (Book) bookDaoImpl.selectById(vid);
    }


}
